import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)


// 公共路由
export const constantRoutes = [
  
  {
    path: '/login',
    name:'login',
    component: () => import('@/views/login'),
    hidden: true,
  },
  {
    path: '/register',
    name:'register',
    component: () => import('@/views/register'),
    hidden: true,
  },
  {
    path: '/',
    redirect: '/login',
    name:'home',
    component: () => import('@/views/home'),
    hidden: true,
  },
  { //基础页面
    path: '/pagesContent',
    name:'pagesContent',
    component: () => import('@/views/pagesContent/index'),
    hidden: true
  },
  
  {
    //订单详情
    path: '/orderDetail',
    name:'orderDetail',
    component: () => import('@/views/orderDetail/index'),
    hidden: true
  },
  
  { //保险详情
    path: '/goodDetail',
    name:'goodDetail',
    component: () => import('@/views/goodDetail/index'),
    hidden: true
  },
  { //保险投保
    path: '/insureAdd',
    name:'insureAdd',
    component: () => import('@/views/insureAdd/index'),
    hidden: true
  },
  { //电梯列表
    path: '/eleAdd',
    name:'eleAdd',
    component: () => import('@/views/eleAdd/index'),
    hidden: true
  },
  
   { //关于我们
    path: '/protocol',
    name:'protocol',
    component: () => import('@/views/protocol/index'),
    hidden: true
  },
   { //关于我们
    path: '/aboutus',
    name:'aboutus',
    component: () => import('@/views/aboutus/index'),
    hidden: true
  },
  { //个人中心
    path: '/personalCenter',
    component: () => import('@/views/personalCenter/index'),
    name:'personalCenter',
    redirect: '/personalCenter/myorder',
    children: [
      {//我的订单
        path: 'myorder',
        name:'myorder',
        component: () => import('@/views/myorder/index'),
      },
      {//我的分润
        path: 'mymoney',
        name:'myMoney',
        component: () => import('@/views/mymoney/index'),
      },
      {//我的提现
        path: 'mytixian',
        name:'mytixian',
        component: () => import('@/views/mytixian/index'),
      },
      {//我的优惠劵
        path: 'discountCoupons',//
        name:'discountCoupons',
        component: () => import('@/views/discountCoupons/index'),
      },
      {//个人信息设置
        path: 'setting',//
        name:'setting',
        component: () => import('@/views/setting/index'),
      },
      {//收货地址
        path: 'address',//
        name:'address',
        component: () => import('@/views/address/index'),
      },
      { //消息通知
        path: 'message',//
        name:'message',
        component: () => import('@/views/message/index'),
      },
    ]
  },
  {
    path: '/api/sms/p/login',
    component: () => import('@/views/login'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/error/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/error/401'),
    hidden: true
  },
  
  
  
]



// 防止连续点击多次路由报错
let routerPush = Router.prototype.push;
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(err => err)
}

export default new Router({
  mode: 'history', // 去掉url中的#
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})
